﻿#include "FITKAbaqusAdaptorInteractionGeneralContact.h"
#include "InpKeyLineSpliter.h"
#include "FITKAbaqusINPReader.h"
#include "FITKAbaqusINPWriter.h"
#include "FITK_Component/FITKAbaqusData/FITKAbaqusPart.h"
#include "FITK_Interface/FITKInterfaceStructural/FITKAbaConstraintCoupling.h" 
#include "FITK_Interface/FITKInterfaceStructural/FITKAbaConstraintTie.h"
#include "FITK_Interface/FITKInterfaceStructural/FITKAbaAssembly.h"
#include "FITK_Interface/FITKInterfaceStructural/FITKAbaAbstractInteraction.h"
#include "FITK_Interface/FITKInterfaceStructural/FITKAbaInteractionManager.h"
#include "FITK_Interface/FITKInterfaceStructural/FITKAbaInteractionPropertyManager.h"
#include "FITK_Interface/FITKInterfaceStructural/FITKAbaInteractionPropertyContact.h"
#include "FITK_Interface/FITKInterfaceStructural/FITKAbaInteractionContactTangentialBehavior.h"
#include "FITK_Interface/FITKInterfaceStructural/FITKAbaInteractionContactBehavior.h"
#include "FITK_Interface/FITKInterfaceStructural/FITKAbaInteractionSurfToSurfExplicit.h"

//命名空间
//备用类后续没用的话可能会被删除
namespace IO
{
    QString FITKAbaqusAdaptorInteractionGeneralContact::getAdaptorClass()
    {
        return "IO::FITKAbaqusAdaptorInteractionGeneralContact";
    }

    void FITKAbaqusAdaptorInteractionGeneralContact::setCaseData(AbaqusData::FITKDataCase* caseData)
    {
        _caseData = caseData;
    }

    bool FITKAbaqusAdaptorInteractionGeneralContact::adaptR()
    {
        _iteractionData = dynamic_cast<Interface::FITKAbaAbstractInteraction*>(_dataObj);
        if (!_iteractionData || !_reader || !_caseData) return false;

        //回退一行 处理关键字信息
        _reader->backLine();

        QString line = _reader->readLine();
        if (!line.toLower().startsWith("*surface interaction")) return false;
        //关键字处理
        InpKeyLineSpliter s(line, _reader);
        QString partname = s["name"];
        _iteractionData->setDataObjectName(partname);
        while (!_reader->atEnd())
        {
            bool readOK = false;
            line = _reader->readLine();
            if (!line.startsWith("*")) continue;

            s.reset(line);
            QString sH = s.getHeader().toLower();
            //发送计算进度信号
            _reader->sendCurrentPercent();
            //有不支持的关键字 异常退出
            //if (sH.isEmpty()) return false;
            if (sH == "contact")
            {
                readOK = readContact();
            }
            else if (sH == "contact clearance")
            {
                readOK = readContactClearance();
            }
            else if (sH == "contact inclusions")
            {
                readOK = readContactInclusions();
            }
            else if (sH == "contact property assignment")
            {
                readOK = readContactPropertyAssignment();
            }

            if (readOK)
            {
                _reader->backLine();
            }
            else 
            {
                return false;
            }
        }
        return false;
    }

    bool FITKAbaqusAdaptorInteractionGeneralContact::adaptW()
    {

        return false;
    }
    bool FITKAbaqusAdaptorInteractionGeneralContact::readContact()
    {
        QString line = _reader->readLine();
        InpKeyLineSpliter s(line, _reader);

        //可选参数
        QString op = s["op"];

        if (op.isEmpty())
        {

        }

        return false;
    }

    bool FITKAbaqusAdaptorInteractionGeneralContact::readContactClearance()
    {
        QString line = _reader->readLine();
        InpKeyLineSpliter s(line, _reader);

        //必选参数
        QString name = s["name"];
        //可选参数
        QString adjust = s["adjust"];
        QString clearance = s["clearance"];
        QString searchAbove = s["search above"];
        QString searchBelow = s["search below"];
        QString searchNset = s["search nset"];


        if (adjust.size() == 3)
        {

        }


        return false;
    }

    bool FITKAbaqusAdaptorInteractionGeneralContact::readContactInclusions()
    {
        return false;
    }
    //读取
    bool FITKAbaqusAdaptorInteractionGeneralContact::readContactPropertyAssignment()
    {
        return false;
    }
    //写出
    bool FITKAbaqusAdaptorInteractionGeneralContact::writeContact()
    {
        return false;
    }
    //写出
    bool FITKAbaqusAdaptorInteractionGeneralContact::writeContactClearance()
    {
        return false;
    }
    //写出
    bool FITKAbaqusAdaptorInteractionGeneralContact::writeContactInclusions()
    {
        return false;
    }
    //写出
    bool FITKAbaqusAdaptorInteractionGeneralContact::writeContactPropertyAssignment()
    {
        return false;
    }
}